<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="${ctx}/css/common.css" />
<jsp:include page="../inc_min.jsp"></jsp:include>
<title>出票信息</title>
<link rel="stylesheet" href="${ctx}/css/page.css"/>
<script type="text/javascript">
	$(function(){
		/* 状态栏动态效果 */
		$(".listArg").click(function(){
			$(".listArg").css({
				"background": "#f1f1f1",
				"color": "black"
			});
			$(this).css({
				"background": "#28aaf0",
				"color": "#FFFFFF"
			});
			//$(".listArg").removeClass("allStatus"); 
			//alert($(this).find("span").attr('id'))
			var orderStatus=$(this).find("span").attr('id');
            getData(orderStatus);
		});

		//点击查询 重新加载列表
		$("#query").click(function(){
            pageNum = 1;
            getData(-1);
		});
        getData(-1);
	});
    var pageNum = 1;
    function getData(orderStatus){
        //出发到达城市清空处理
        alsoempty($("#homecity_name"),$("#_startCity"));
        alsoempty($("#getcity_name"),$("#_endCity"));
        //获取参数
        var orderNumber=$("#_orderNumber").val();
        var toStartAirportCode=$("#_startCity").val();
        var toEndAirportCode=$("#_endCity").val();
        var toStartDate=$("#startDate").val();
        var toEndDate=$("#endDate").val();
        if(typeof(toStartAirportCode) == 'undefined'){
            toStartAirportCode = "";
        };
        if(typeof(toEndAirportCode) == 'undefined'){
            toEndAirportCode = "";
        };
        var param = {
            "orderNumber":orderNumber,
            "toStartAirportCode":toStartAirportCode,
            "toEndAirportCode":toEndAirportCode,
            "toStartDate":toStartDate,
            "toEndDate":toEndDate,
            "orderStatus":orderStatus,
            "page":pageNum,
            "rows":20
        }
        $.get('${ctx}/search/getBuyerList?temp='+Math.random(),param,function(data){
            $('table tbody').empty();
            var str = "";
            for(var i=0;i<data.rows.length;i++){
                var obj = data.rows[i];
                var intervalDay=CommonConverter.toEmptyStr(obj.list[0].intervalDay);
                if(intervalDay != 0){
                    intervalDay ="+"+intervalDay;
                };
                str+="<tr class='reBorder' height='40px'>"
                str+="	<td colspan='8'>"
                str+="		<span class='orderNumberSpan'>订单号："+obj.orderNumber+"</span>"
                str+="	</td>"
                str+="</tr>"
                str+="<tr height='90px'>"
                str+="	<td align='center'>"
                str+="		往：<span style='color:black;'>"+obj.list[0].airlineNumber+"</span><br/>"
                str+= (obj.list.length==2) ?  "返：<span style='color:black;'>"+obj.list[1].airlineNumber+"</span>" :  "";
                str+="	</td>"
                str+="	<td align='right'>"
                str+="		<span>"+CommonConverter.formatFlightTime((obj.list)[0].deptTime)+"</span><br/>"
                str+="		<span style='color:#444e50'>"+obj.list[0].deptCity+"</span><span style='color:#444e50'>("+obj.list[0].deptCode+")</span><span style='color:#e2615c'>"+obj.list[0].deptTerminal+"</span><br/>"
                str+= (obj.list.length==2) ?  "<span>"+CommonConverter.formatFlightTime((obj.list)[1].arrTime)+"</span><br/>" :  "";
                str+="	</td>"
                str+="	<td align='center'>"
                str+="		<span style='color:#23b9dc'>"+obj.list[0].deptDate+"</span><br/>"
                str+= (obj.list.length==2) ?  "<img src='${ctx}/image/flightQuery/round.gif'><br/>" :  "<img src='${ctx}/image/flightQuery/dancheng.png'><br/>";
                str+= (obj.list.length==2) ?  "<span style='color:#23b9dc'>"+obj.list[1].deptDate+"</span><br/>" :  "";
                str+="	</td>"
                str+="	<td>"
                str+="		<span>"+CommonConverter.formatFlightTime((obj.list)[0].arrTime)+"</span><span style='color:#e2615c;'>"+intervalDay+"</span><br/>"
                str+="		<span style='color:#444e50'>"+obj.list[0].arrCity+"</span><span style='color:#444e50'>("+obj.list[0].arrCode+")</span><span style='color:#e2615c'>"+obj.list[0].arrTerminal+"</span><br/>"
                str+= (obj.list.length==2) ?  "<span>"+CommonConverter.formatFlightTime((obj.list)[1].deptTime)+"</span><br/>" :  "";
                str+="	</td>"
                str+="	<td width='88px' align='center'>"+CommonConverter.toEmptyString(obj.sellingPrice)+"</td>"
                str+="	<td width='86px' align='center'>"+CommonConverter.toEmptyString(obj.purchQuantity)+"</td>"
                str+="	<td width='96px' align='center' style='color:black'>"+CommonConverter.toEmptyString(obj.sum)+"</td>"
                str+="	<td width='151px' align='center' style='color:#e2615c'>"+CommonConverter.toOrderBizStatusStr(obj.orderStatus)+"</td>"
                str+="</tr>"
            }
            $('#tb').append(str);
            //显示分页
            layui.use(['laypage', 'layer'], function(){
                var laypage = layui.laypage;
                laypage({
                    cont: 'pager'
                    ,pages:  Math.ceil(data.total/20) //得到总页数 //总页数
                    ,groups: 5 //连续显示分页数
                    ,skin: '#1E9FFF'
                    ,curr : pageNum
                    ,jump: function(obj,first){
                        if(!first){
                            pageNum = obj.curr;
                            getData(orderStatus);
                        }
                    }
                });
            });
        })
    }
	//如果为空  对应的文本框为空
	function alsoempty(a,b){
		if(a.val() == "中文/拼音"){
			b.val("");
		};
	};
</script>
</head>
<body>
<jsp:include page="../head.jsp"/>
	<div class="content">
			<ul class="list">
					<li>订单号：<input style='width:120px;height:18px' id="_orderNumber" /></li>
					<!-- <li>
						出票状态：
						<select id="orderStatus" style="width: 73px;">
							<option value="-1">全部</option>
							<option value="0">待支付</option>
							<option value="2">待出票</option>
							<option value="4">出票完成</option>
							<option value="5">已取消</option>
						</select>
					</li> -->
					<li>去程出发：
					<input type="text" value="" size="15" id="homecity_name" name="homecity_name" style="width:150px;height: 18px" mod="address|notice" mod_address_source="hotel" mod_address_suggest="" mod_address_reference="_startCity" mod_notice_tip="中文/拼音" />
					<input id="_startCity" name="_startCity" type="hidden" value="" />
					</li>
					<li>去程到达：
					<input type="text" value="" size="15" id="getcity_name" name="getcity_name" style="width:150px;height: 18px" mod="address|notice" mod_address_source="hotel"  mod_address_reference="_endCity" mod_notice_tip="中文/拼音" />
					<input id="_endCity" name="_endCity" type="hidden" value="" />
					</li>
					<li>
						 出发时间：<input type="text" id="startDate" class="Wdate"  value="${requestScope.deptDate}" onFocus="new WdatePicker({dateFmt:'yyyy-MM-dd'/*,minDate:'%y-%M-\#{%d+2}',maxDate:'#F{$dp.$D(\'endDate\')}'*/})"/>
						&nbsp;&nbsp;&nbsp;&nbsp;
						至<input type="text" id="endDate" class="Wdate"  value="${requestScope.endDate}" onFocus="new WdatePicker({dateFmt:'yyyy-MM-dd'/*,minDate:'#F{$dp.$D(\'startDate\')}'*/})">
					</li>
					<li class="right"><button class='query' id="query">查询</button></li>
				</ul>
				<ul class="list conditionList">
					<li>状态：</li>
					<li class="listArg allStatus">
						<span id="-1" />全部</span>
					</li>
					<li class="listArg">
                        <span id="0">待支付</span>
					</li>
					<li class="listArg">
						<span id="2">待出票</span>
					</li>
					<li class="listArg">
						<span id="4">出票完成</span>
					</li>
					<li class="listArg">
						<span id="5">已取消</span>
					</li>
				</ul>
				<table class="conTable" style="margin-top:0;">
					<thead>
						<tr height="38" >
							<td width="165" align="center"><img src="${ctx}/image/flightQuery/flightNumber.gif">航班号</td>
							<td width="241" align="right"><img src="${ctx}/image/flightQuery/flightStart.gif">出发</td>
							<td width="157" align="center">&nbsp;&nbsp;&nbsp;</td>
							<td width="241"><img src="${ctx}/image/flightQuery/flightEnd.gif">到达</td>
							<td width="117" align="center"><img src="${ctx}/image/price.gif">单价</td>
							<td width="115" align="center"><img src="${ctx}/image/amount.gif">数量</td>
							<td width="129" align="center"><img src="${ctx}/image/price.gif">总价</td>
							<td width="135" align="center"><img src="${ctx}/image/status.gif">状态</td>
						</tr>
					</thead>
					<tbody id="tb">

					</tbody>
			</table>
			<!-- 分页 -->
       		 <div id="pager" class="divBox"></div>
		</div>
<script type="text/javascript" src="${ctx }/jslib/airport/fixdiv.js"></script>
<script type="text/javascript" src="${ctx }/jslib/airport/address.js"></script>
<jsp:include page="../footer.jsp"/>
</body>
</html>